home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / duplfile.bat < prev    next >
DOS Batch File  |  1994-07-01  |  1KB  |  47 lines

  1. @echo off
  2. !  duplfile.bat    Batch file to duplicate a file
  3. !
  4. !  duplfile name
  5. !
  6. !  where 'name' is the file to be duplicated. The name can be preceded by
  7. !  a path and a volume ID.
  8. !
  9. !  duplfile.bat calls uniqueName and extractPath
  10. !
  11. !  Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
  12. !
  13.  
  14.     ! ensure that the first parameter is there and that the second one is not
  15.     set doserr=13
  16.     if not "%2 " == " " goto ERR_LBL
  17.     if "%1 " == " " goto ERR_LBL
  18.  
  19.     ! ensure that the requested file is there
  20.     set doserr=27
  21.     if not exist "%1" goto ERR_LBL
  22.  
  23.     ! make the new name and check that it is valid
  24.     call uniqueName "%1" duplfile_newName
  25.     if not %doserr% == 0 goto ERR_LBL
  26.  
  27.     ! do the actual duplication
  28.     call extractPath "%1" duplfile_path
  29.     if not %doserr% == 0 goto ERR_LBL
  30.     if "%duplfile_path%" == %%DUPLFILE_PATH%% goto WITHOUT_PATH_LBL
  31.     incr duplfile_path by "%duplfile_newName%"
  32.     goto DO_COPY_LBL
  33. :WITHOUT_PATH_LBL
  34.     set duplfile_path=%duplfile_newName%
  35. :DO_COPY_LBL
  36.     copy "%1" "%duplfile_path%"
  37.     set doserr=0
  38.     goto DONE_LBL
  39.  
  40. :ERR_LBL
  41.     show %doserr%
  42.  
  43. :DONE_LBL
  44.     ! remove the global variables
  45.     set duplfile_newName=
  46.     set duplfile_path=
  47.